package com.ncloud.chnl.mapper;
import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.ncloud.chnl.entity.CustArea;  
@Mapper
public interface CustAreaMapper{  
  
    @Select(value = { "select * from bs_cust_area where area_id = #{areaId} and state='1'" })
    @Results({ @Result(column = "cust_id", property = "custId"), @Result(column = "area_id", property = "areaId"),  
        @Result(column = "area_name", property = "areaName"),@Result(column="remark",property="remark"),
        @Result(column="create_time",property="createTime"),@Result(column="update_time",property="updateTime"),
        @Result(column="create_user",property="createUser"),@Result(column = "update_user", property = "updateUser")})
    public CustArea getCustArea(Long areaId);
  
    @Select(value = { "select * from bs_cust_area where cust_id = #{custId} and state='1'" })  
    @Results({ @Result(column = "cust_id", property = "custId"), @Result(column = "area_id", property = "areaId"),  
            @Result(column = "area_name", property = "areaName"),@Result(column="remark",property="remark"),
            @Result(column="create_time",property="createTime"),@Result(column="update_time",property="updateTime"),
            @Result(column="create_user",property="createUser"),@Result(column = "update_user", property = "updateUser")})  
    public List<CustArea> getAllCustAreas(Long custId);

    @Insert(value = ("insert into bs_cust_area(cust_id,area_id,area_name,state,create_time,create_user,update_time,update_user,remark)"
    		+ " values (#{custId},#{areaId},#{areaName},#{state},#{createTime},#{createUser},#{updateTime},#{updateUser},#{remark})"))
    public int insertCustArea(CustArea custArea);
    
    @Update(value = ("update bs_cust_area set area_name = #{areaName},update_time = now(),"
    		+ " update_user = #{updateUser},remark = #{remark} where area_id = #{areaId}"))
    public int updateCustArea(CustArea custArea);

    @Update("update bs_cust_area set update_time = now(),state=#{state},"
    		+ " update_user = #{updateUser},remark = #{remark} where area_id = #{areaId}")
	public int deleteCustAreaInfo(CustArea custArea);
    
//    @Delete(value = ("delete from bs_cust_area where area_id = #{areaId}"))
//    public int deleteCustArea(Long areaId);
    
} 